package unclassified.simple;

import java.util.HashSet;
import java.util.Set;

public class RearrangeCharactersToMakeTargetString_6078 {

    public int rearrangeCharacters(String s, String target) {
        int[] arr = new int[26];

        for(Character c : s.toCharArray()) {
            arr[c - 'a']++;
        }
        int count = 0;
        while (true) {
            for (int i = 0; i < target.length(); i++) {
                if (arr[target.charAt(i) - 'a'] == 0) {
                    return count;
                }
                arr[target.charAt(i) - 'a']--;
            }
            count++;
        }
    }

    public static void main(String[] args) {
        RearrangeCharactersToMakeTargetString_6078 rr = new RearrangeCharactersToMakeTargetString_6078();
        System.out.println(rr.rearrangeCharacters("ilovecodingonleetcode", "code"));
    }
}
